package edu.office.sessionRepository;

import edu.office.applicationRepository.NewsRepository;
import edu.office.applicationRepository.RoleinfoRepository;
import edu.office.applicationRepository.TeacherAdminRepository;
import edu.office.entities.News;
import edu.office.tools.StaticFields;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;

@Named
@SessionScoped
public class TeaNewsBean implements Serializable {
    @Inject
    RoleinfoRepository applicationRoleinfoController;
    @Inject
    NewsRepository applicationNewsController;
    @Inject
    TeacherAdminRepository teacherAdminController;
    private News news = new News();
    private List<News> recentNews;
    private LinkedHashMap<String, List<News>> recentNewsMap;
    private News directNews;

    @PostConstruct
    public void init() {
        StaticFields.TEA_NEWS_COUNT = applicationNewsController.getNews4Roleinfo(applicationRoleinfoController.getTeacherRoleinfo().getID()).size();
        StaticFields.STU_NEWS_COUNT = applicationNewsController.getNews4Roleinfo(applicationRoleinfoController.getStudentRoleinfo().getID()).size();
    }



}
